<?php
if(!defined('INSIDE')){
	exit("Access Denied");
}

class item_populator{
	public static function populate_nav(){
		$ret = array();
		$query = 'select a.nav_id, a.desc, a.href from wb_nav a order by a.priority';
		$res_nav = DB::query($query);
		while($row_nav = DB::fetch_assoc($res_nav)){
			$nav = array();
			$nav['desc']=$row_nav['desc'];
			$nav['href']=$row_nav['href'];
			$query = 'select a.desc, a.href from wb_nav_subs a where a.nav_id=\''.$row_nav['nav_id'].'\' order by a.priority';
			$res_sub = DB::query($query);
			$subs = array();
			while($row_sub = DB::fetch_assoc($res_sub)){
				$sub = array();
				$sub['desc']=$row_sub['desc'];
				$sub['href']=$row_sub['href'];
				array_push($subs, $sub);
			}
			$nav['subs']=$subs;
			array_push($ret, $nav);
		}
		return $ret;
	}
}
?>